project (syncctl)

cmake_minimum_required (VERSION 2.6.2)
set (CMAKE_VERBOSE_MAKEFILE 1)
if (COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
endif (COMMAND cmake_policy)

install(FILES etc/cron.d/sync DESTINATION /etc/cron.d)

install(FILES etc/sync/nodes.conf DESTINATION /etc/sync)
install(FILES etc/sync/nodes.sec DESTINATION /etc/sync)
install(FILES etc/sync/sync.conf DESTINATION /etc/sync)

install(PROGRAMS etc/sync/sync.isql DESTINATION /etc/sync)
install(PROGRAMS etc/sync/tables.sh DESTINATION /etc/sync)

install(PROGRAMS usr/bin/archive DESTINATION /usr/bin)
install(PROGRAMS usr/bin/nodeconf DESTINATION /usr/bin)
install(PROGRAMS usr/bin/office.to DESTINATION /usr/bin)
install(PROGRAMS usr/bin/syncctl DESTINATION /usr/bin)

install(FILES usr/lib/sync/common DESTINATION /usr/lib/sync)
install(FILES usr/lib/sync/postgre.sql DESTINATION /usr/lib/sync)

install(DIRECTORY DESTINATION "/var/opt/arch")
install(DIRECTORY DESTINATION "/var/spool/uucppublic")

set(CPACK_GENERATOR "DEB")
#   CPACK_INSTALL_CMAKE_PROJECTS        - For each project (path, name, component)
#   CPACK_CMAKE_GENERATOR               - CMake Generator used for the projects
#   CPACK_INSTALL_COMMANDS              - Extra commands to install components
#   CPACK_INSTALL_DIRECTORIES
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_BINARY_DIR}/usr/share/doc/sync/changelog.Debian")
#   CPACK_PACKAGE_DESCRIPTION_SUMMARY   - Summary of the package
#   CPACK_PACKAGE_EXECUTABLES           - List of pairs of executables and labels
#   CPACK_PACKAGE_FILE_NAME             - Name of the package generated
#   CPACK_PACKAGE_ICON                  - Icon used for the package
#   CPACK_PACKAGE_INSTALL_DIRECTORY     - Name of directory for the installer
set(CPACK_PACKAGE_NAME "sync")
set(CPACK_PACKAGE_VENDOR "mobilcard")
set(CPACK_PACKAGE_VERSION "3.3")
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "3")
set(CPACK_PACKAGE_VERSION_PATCH "5")

#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_BINARY_DIR}/usr/share/doc/sync/copyright")

set(CPACK_DEBIAN_PACKAGE_DEPENDS "uucp, gnupg, postgresql, ckermit, mgetty")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Konkov Vladimir")

include(CPack)

include(CTest)

add_test(SetUpDataBase ../test/createdb.sh)
add_test(SystemInstall ../test/system_install.sh)
add_test(SystemUpdate syncctl system update)
add_test(SystemStatus syncctl system status)
add_test(NodeAdd syncctl node add kemerovo)
add_test(NodeReset syncctl node reset kemerovo)
add_test(NodeList syncctl node list)
add_test(TableAdd ../test/tables.sh)
add_test(TableUpdate ../test/tables_update.sh)
add_test(TableDwatchOn syncctl table dwatch_on public.mcs_shifts)
add_test(TableDwatchOff syncctl table dwatch_off public.mcs_shifts)
add_test(DataPrepare syncctl data prepare for kemerovo)
add_test(DataUpdate syncctl data update from kemerovo)
add_test(PreparedSet syncctl prepared set 0 for kemerovo)
add_test(PreparedGet syncctl prepared get for kemerovo)
add_test(UpdatedSet syncctl updated set 0 for kemerovo)
add_test(UpdatedGet syncctl updated get for kemerovo)
add_test(TableRemove syncctl table remove public.mcs_shifts)
add_test(NodeRemove syncctl node remove kemerovo)
add_test(SystemUninstall syncctl system uninstall)

#set_tests_properties(SetUpDataBase SystemInstall SystemUninstall SystemStatus NodeAdd NodeReset NodeRemove NodeList TableAdd TableUpdate TableRemove TableDwatchOn TableDwatchOff DataPrepare DataUpdate PreparedSet PreparedGet UpdatedSet UpdatedGet PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR")


